package com.team7.happycommunity.parkservice.dao;

import com.team7.happycommunity.parkservice.dto.MyParkingRecordsDTO;
import com.team7.happycommunity.parkservice.pojo.ParkingRentRecords;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ParkingRentRecordsMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(ParkingRentRecords record);

    int insertSelective(ParkingRentRecords record);

    ParkingRentRecords selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(ParkingRentRecords record);

    int updateByPrimaryKey(ParkingRentRecords record);

    @Select("select * from parking_rent_records where parking_info_id = #{id}")
    List<ParkingRentRecords> selectByParkingInfoId(Integer id);


    @Select("select r.begin_time beginTime, r.end_time endTime, r.carid carId, " +
            " a.area_name areaName,p.parking_number parkingNumber,p.cost_per_day costPerDay from parking_rent_records r left join " +
            "parking_info p on p.id = r.parking_info_id " +
            "left join areainfo a on a.id = p.community_id " +
            "where r.user_id = #{id}")
    List<MyParkingRecordsDTO> selectByUserId(Integer id);
}